//package org.activoricordi.app.snippet
package edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.snippet

/**
 * Created with IntelliJ IDEA.
 * User: naru
 * Date: 3/30/13
 * Time: 12:23 PM
 * To change this template use File | Settings | File Templates.
 */
import net.liftweb.common.{Box,Full,Empty,Failure,ParamFailure}
import net.liftweb._
import  edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.model._
import util._
import Helpers._
import http._

import scala.xml._


class ListCompound {

  def list(html: NodeSeq) : NodeSeq = {
    /**
     * bind all Compound in list format to list view
     */
    toShow.flatMap(compound =>
      bind("compound", html,
        "compoundName" -> compound.compoundName,
       "method"  -> compound.method,
        "inchiKey" -> compound.inchiKey,
        "retentionTime" ->compound.retentionTime,
        "theoreticalMass" -> compound.theoreticalMass,

        /**
         * view link for Compound
         */
        FuncAttrBindParam("view_href", _ =>
          Text("view/"+ (compound.primaryKeyField)),"href"),

        /**
         * edit link for Compound
         */
        FuncAttrBindParam("edit_href", _ =>
          Text("edit/"+ (compound.primaryKeyField)),"href"),

        /**
         * delete link for Compound
         */
        FuncAttrBindParam("delete_href", _ =>
          Text("delete/"+ (compound.primaryKeyField)),"href")
      )
    )
  }

  /**
   * Compound object input to list all Compounds
   *
   */
  private def toShow =
    Compound.findAll();


}
